package com.lvyq.qrobot.service.impl;

import com.lvyq.qrobot.common.MsgType;
import com.lvyq.qrobot.locadata.LocalDataLst;
import com.lvyq.qrobot.model.receive.ReceiveMsg;
import com.lvyq.qrobot.model.send.SendParam;
import com.lvyq.qrobot.server.local.LocalServer;
import com.lvyq.qrobot.server.remote.RemoteServer;
import com.lvyq.qrobot.service.MsgDispenseService;
import com.lvyq.qrobot.util.CommonUtil;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @author lvyq  消息处理
 * @version 1.0
 * Create by 2024-05-31 10:09
 */
@Service
public class MsgDispenseServiceImpl implements MsgDispenseService {


    /**
     * @description 消息处理
     * @author lvyq
     * @param[1] toString
     * @throws 
     * @time 2024-05-31 10:12
     */
    @Override
    public void dispenseMsg(ReceiveMsg vo) {

        if (MsgType.GROUP.equals(vo.getMessageType())){
            String reOrder= CommonUtil.orderConvert(vo.message);
            List<String> list = LocalDataLst.list();
            SendParam param = new SendParam();
            param.setGroup_id(vo.groupId);
            if (list.contains(vo.message) || list.contains(reOrder)){
                LocalServer.sendMsg(param,vo);
            }else {
                //穿越皇朝
                RemoteServer.sendMsg(param,vo,reOrder);
            }
        }
    }


}
